home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-11 | 4.4 KB | 276 lines | [TEXT/CWIE] |
- // DReminder.cp -- data container class for AMReminder
-
- #include "DReminder.h"
-
- #include <LFileStream.h>
-
- #include <DateTimeUtils.h>
-
- //----------
- DReminder::DReminder ()
- {
- GetLongDateTime (&mDateTime);
- LString::CopyPStr ("\p", mMessage);
- mShowAlert = false;
- mShowIcon = false;
- mPlaySound = false;
- mSoundIndex = 1;
- }
-
- //----------
- DReminder::~DReminder ()
- {
- }
-
- //----------
- void DReminder::CopyFrom (
- DReminder* inOther)
- {
- mDateTime = inOther->mDateTime;
- LString::CopyPStr (inOther->mMessage, mMessage);
- mShowAlert = inOther->mShowAlert;
- mShowIcon = inOther->mShowIcon;
- mPlaySound = inOther->mPlaySound;
- mSoundIndex = inOther->mSoundIndex;
- }
-
- //----------
- void DReminder::ReadFromFile (
- LFileStream* inFile)
- {
- inFile->ReadBlock (&mDateTime, sizeof (mDateTime));
- inFile->ReadPString (mMessage);
- inFile->ReadBlock (&mShowAlert, sizeof (mShowAlert));
- inFile->ReadBlock (&mShowIcon, sizeof (mShowIcon));
- inFile->ReadBlock (&mPlaySound, sizeof (mPlaySound));
- inFile->ReadBlock (&mSoundIndex, sizeof (mSoundIndex));
- }
-
- //----------
- void DReminder::WriteToFile (
- LFileStream* inFile)
- {
- inFile->WriteBlock (&mDateTime, sizeof (mDateTime));
- inFile->WritePString (mMessage);
- inFile->WriteBlock (&mShowAlert, sizeof (mShowAlert));
- inFile->WriteBlock (&mShowIcon, sizeof (mShowIcon));
- inFile->WriteBlock (&mPlaySound, sizeof (mPlaySound));
- inFile->WriteBlock (&mSoundIndex, sizeof (mSoundIndex));
- }
-
-
- //----------
- LongDateRec DReminder::GetDateTime () const
- {
-
- return mDateTime;
- }
-
- //----------
- void DReminder::SetDateTime (
- LongDateRec inValue)
- {
- mDateTime = inValue;
-
- SignalDataChanged (idDateTime);
- }
-
-
- //----------
- StringPtr DReminder::GetMessage (
- Str255 outPtr) const
- {
-
- if (outPtr != nil) {
- LString::CopyPStr (mMessage, outPtr);
- }
- return (StringPtr)mMessage;
- }
-
- //----------
- void DReminder::SetMessage (
- ConstStringPtr inValue)
- {
- LString::CopyPStr (inValue, mMessage);
-
- SignalDataChanged (idMessage);
- }
-
- //----------
- void DReminder::SetMessage (
- CharsHandle inValue)
- {
- SetPStr (mMessage, sizeof (mMessage), inValue);
-
- SignalDataChanged (idMessage);
- }
-
-
- //----------
- Boolean DReminder::GetShowAlert () const
- {
-
- return mShowAlert;
- }
-
- //----------
- void DReminder::SetShowAlert (
- Boolean inValue)
- {
- mShowAlert = inValue;
-
- SignalDataChanged (idShowAlert);
- }
-
-
- //----------
- Boolean DReminder::GetShowIcon () const
- {
-
- return mShowIcon;
- }
-
- //----------
- void DReminder::SetShowIcon (
- Boolean inValue)
- {
- mShowIcon = inValue;
-
- SignalDataChanged (idShowIcon);
- }
-
-
- //----------
- Boolean DReminder::GetPlaySound () const
- {
-
- return mPlaySound;
- }
-
- //----------
- void DReminder::SetPlaySound (
- Boolean inValue)
- {
- mPlaySound = inValue;
-
- SignalDataChanged (idPlaySound);
- }
-
-
- //----------
- SInt16 DReminder::GetSoundIndex () const
- {
-
- return mSoundIndex;
- }
-
- //----------
- void DReminder::SetSoundIndex (
- SInt16 inValue)
- {
- mSoundIndex = inValue;
-
- SignalDataChanged (idSoundIndex);
- }
-
-
- //----------
- StringPtr DReminder::GetDateString (
- Str255 outPtr) const
- {
- LongDateTime longSeconds;
- static Str255 dateString;
-
- LongDateToSeconds (&mDateTime, &longSeconds);
- LongDateString (&longSeconds, shortDate, dateString, nil);
-
- return dateString;
-
- }
-
- //----------
- void DReminder::SetDateString (
- ConstStringPtr inValue)
- {
-
- SignalDataChanged (idDateString);
- }
-
- //----------
- void DReminder::SetDateString (
- CharsHandle inValue)
- {
-
- SignalDataChanged (idDateString);
- }
-
-
- //----------
- StringPtr DReminder::GetTimeString (
- Str255 outPtr) const
- {
- LongDateTime longSeconds;
- static Str255 timeString;
-
- LongDateToSeconds (&mDateTime, &longSeconds);
- LongTimeString (&longSeconds, false, timeString, nil);
-
- return timeString;
-
- }
-
- //----------
- void DReminder::SetTimeString (
- ConstStringPtr inValue)
- {
-
- SignalDataChanged (idTimeString);
- }
-
- //----------
- void DReminder::SetTimeString (
- CharsHandle inValue)
- {
-
- SignalDataChanged (idTimeString);
- }
-
-
- //----------
- LongDateRec DReminder::GetYearMonthDay () const
- {
- return mDateTime;
-
- }
-
- //----------
- void DReminder::SetYearMonthDay (
- LongDateRec inValue)
- {
- mDateTime.ld.year = inValue.ld.year;
- mDateTime.ld.month = inValue.ld.month;
- mDateTime.ld.day = inValue.ld.day;
- SignalDataChanged (idDateTime);
-
- SignalDataChanged (idYearMonthDay);
- }
-
-
- //----------
- LongDateRec DReminder::GetHourMinute () const
- {
- return mDateTime;
-
- }
-
- //----------
- void DReminder::SetHourMinute (
- LongDateRec inValue)
- {
- mDateTime.ld.hour = inValue.ld.hour;
- mDateTime.ld.minute = inValue.ld.minute;
- SignalDataChanged (idDateTime);
-
- SignalDataChanged (idHourMinute);
- }
-